//
//  PlayTableViewCell.m
//  New
//
//  Created by dlios on 15-7-20.
//  Copyright (c) 2015年 yangTao. All rights reserved.
//

#import "PlayTableViewCell.h"

@implementation PlayTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self creatSubView];
    }
    return self;
    
}
-(void)creatSubView{
   
    self.imageV = [[UIImageView alloc]initWithFrame:CGRectMake(15, 5, 20, 20)];
    self.imageV.layer.cornerRadius = 10;
    self.imageV.image = [UIImage imageNamed:@"iconfont-yuanquanxuanzhong-2.png"];
    [self addSubview:self.imageV];
    
    self.view = [[UIView alloc]initWithFrame:CGRectMake(25, 0, 1, self.frame.size.height)];
    self.view.backgroundColor = [UIColor blueColor];
    [self addSubview:self.view];

    
    if (WIDTH >= 375) {
        self.context = [[BaseLabel alloc]initWithFrame:CGRectMake(50, 0, self.frame.size.width , self.frame.size.height)];
        self.context.backgroundColor =[UIColor clearColor];
        self.context.numberOfLines = 0;
        [self addSubview:self.context];
    }else{
    
        self.context = [[BaseLabel alloc]initWithFrame:CGRectMake(40, 0, self.frame.size.width- 50 , self.frame.size.height)];
        self.context.backgroundColor =[UIColor clearColor];
        self.context.numberOfLines = 0;
        [self addSubview:self.context];
    
    }
    
    
    
}
-(void)setPlay:(PlayModel *)play{
    if (_play != play) {
        _play = play;
    }


    self.context.text = play.title;


}

//-(void)setContextText:(NSString *)text{
//
//    CGRect frame = [self frame];
//    self.context.text = text;
//      self.context.numberOfLines = 10;
//    CGSize size = CGSizeMake(300, 1000);
//
//    
////    NSStringDrawingOptions option = NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
////    
////    //NSStringDrawingTruncatesLastVisibleLine如果文本内容超出指定的矩形限制，文本将被截去并在最后一个字符后加上省略号。 如果指定了NSStringDrawingUsesLineFragmentOrigin选项，则该选项被忽略 NSStringDrawingUsesFontLeading计算行高时使用行间距。（译者注：字体大小+行间距=行高）
////    
////    NSDictionary *attributes = [NSDictionary dictionaryWithObject:self.context.font forKey:NSFontAttributeName];
////    
////    CGRect labelSize = [self.context.text boundingRectWithSize:size options:option attributes:attributes context:nil];
////    self.context.frame = CGRectMake(self.context.frame.origin.x, self.context.frame.origin.y, labelSize.size.width, labelSize.size.height) ;
//    
//    CGSize labelSize = [self.context.text sizeWithFont:self.context.font constrainedToSize:size lineBreakMode:NSLineBreakByClipping];
//    self.context.frame = CGRectMake(self.context.frame.origin.x, self.context.frame.origin.y, labelSize.width, labelSize.height);
//    
//    
//    frame.size.height = labelSize.height + 100;
//    
//    self.frame = frame;
//
//}

@end
